﻿using System.Data;
using ET;
namespace DAL
{
    public class Proposed_Detail_DAL : clsConnect
    {
        private static readonly clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable GetDataProposedTemp(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_Id", id);
            return cls.GetData("sp_tb_Proposed_Detail_Temp_Get");
        }
        public DataTable GetDataProposedTempEdit(int id,int id_1)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_Id", id);
            cls.AddParameter("@Proposed_ID",id_1);
            return cls.GetData("sp_tb_Proposed_Detail_Temp_Get_Edit");
        }
        public DataTable GetDataProposedTempActive(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_Id", id);
            return cls.GetData("sp_tb_Proposed_Detail_Active");
        }
        public DataTable GetDataProposedTempEditQuality(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_Detail_ID", id);
            return cls.GetData("sp_tb_Proposed_Detail_Temp_Edit");
        }
        public DataTable GetDataProposedTempSum(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_Id", id);
            return cls.GetData("sp_tb_Proposed_Detail_Sum");
        }
        public DataTable GetDataProposedTempSumEdit(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_ID", id);
            return cls.GetData("sp_tb_Proposed_Detail_Sum_Edit");
        }
        public DataTable GetDataProposedQualityStill(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_ID", id);
            return cls.GetData("sp_tb_Proposed_Detail_Temp_Get_Still");
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertProposedDetail(Proposed_Detail_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_ID", data.Proposed_ID);
            cls.AddParameter("@Order_Buy_Id", data.Order_Buy_Id);
            cls.AddParameter("@Materials_Id", data.Materials_Id);
            cls.AddParameter("@Proposed_Quality", data.Proposed_Quality);
            cls.AddParameter("@Proposed_Price", data.Proposed_Price);
            cls.AddParameter("@Proposed_Percent_CK", data.Proposed_Percent_CK);
            cls.AddParameter("@Proposed_CK_Total", data.Proposed_CK_Total);
            cls.AddParameter("@Proposed_Percent_VAT", data.Proposed_Percent_VAT);
            cls.AddParameter("@Proposed_VAT_Total", data.Proposed_VAT_Total);
            cls.AddParameter("@Proposed_Total_Price", data.Proposed_Total_Price);
            cls.AddParameter("@Proposed_DateBegin", data.Proposed_DateBegin);
            cls.AddParameter("@Users_Id", data.Users_Id);
            cls.AddParameter("@Proposed_Descripttion", data.Proposed_ID);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Detail_Insert");
        }
        public bool InsertProposedDetailMaterial(Proposed_Detail_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Materials_Id", data.Materials_Id);
            cls.AddParameter("@Proposed_Price", data.Proposed_Price);
            cls.AddParameter("@Proposed_Percent_CK", data.Proposed_Percent_CK);
            cls.AddParameter("@Proposed_Percent_VAT", data.Proposed_Percent_VAT);
            cls.AddParameter("@Users_Id", data.Users_Id);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Detail_Insert_Material");
        }
        public bool InsertProposedDetailMaterialTemp(Proposed_Detail_Temp_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Order_Buy_Detail_Id", data.Order_Buy_Detail_Id);
            cls.AddParameter("@Users_Id", data.Users_Id);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Insert_Material");
        }
        public bool InsertProposedDetailMaterialTempEdit(Proposed_Detail_Temp_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Order_Buy_Detail_Id", data.Order_Buy_Detail_Id);
            cls.AddParameter("@Users_Id", data.Users_Id);
            cls.AddParameter("@Proposed_ID", data.Proposed_ID);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Insert_Material_Edit");
        }
        public bool UpdateQualityProposedDetail(Proposed_Detail_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_Detail_ID", data.Proposed_Detail_ID);
            cls.AddParameter("@Proposed_Quality", data.Proposed_Quality);
            cls.AddParameter("@Proposed_Price", data.Proposed_Price);
            cls.AddParameter("@Proposed_Percent_CK", data.Proposed_Percent_CK);
            cls.AddParameter("@Proposed_Percent_VAT", data.Proposed_Percent_VAT);
            cls.AddParameter("@Users_Id", data.Users_Id);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Detail_Update_Quality");
        }
        public bool UpdateQualityProposedDetailTemp(Proposed_Detail_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_Detail_ID", data.Proposed_Detail_ID);
            cls.AddParameter("@Order_Buy_Id", data.Order_Buy_Id);
            cls.AddParameter("@Proposed_Quality", data.Proposed_Quality);
            cls.AddParameter("@Materials_Id", data.Materials_Id);
            cls.AddParameter("@Proposed_DateBegin", data.Proposed_DateBegin);
            cls.AddParameter("@Proposed_Price", data.Proposed_Price);
            cls.AddParameter("@Proposed_Percent_CK", data.Proposed_Percent_CK);
            cls.AddParameter("@Proposed_Percent_VAT", data.Proposed_Percent_VAT);
            cls.AddParameter("@Users_Id", data.Users_Id);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Update_Quality_Temp");
        }
        public bool UpdateQualityProposedDetailTempEdit(Proposed_Detail_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Proposed_Detail_ID", data.Proposed_Detail_ID);
            cls.AddParameter("@Proposed_Quality", data.Proposed_Quality);
            cls.AddParameter("@Proposed_DateBegin", data.Proposed_DateBegin);
            cls.AddParameter("@Proposed_Price", data.Proposed_Price);
            cls.AddParameter("@Proposed_Percent_CK", data.Proposed_Percent_CK);
            cls.AddParameter("@Proposed_Percent_VAT", data.Proposed_Percent_VAT);
            cls.AddParameter("@Users_Id", data.Users_Id);
            return cls.ExecuteNonQuery("sp_tb_Proposed_Update_Quality_Temp_Edit");
        }
        public bool DeleteProposedTemp(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Users_Id", id);
            cls.ExecuteNonQuery("sp_tb_Proposed_Detail_Temp_Delete");
            return true;
        }
        #endregion
    }
}
